package com.zkx.blogweb.mapper.service;

import com.zkx.blogweb.entity.Bolg;
import com.zkx.blogweb.mapper.BolgMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zkx
 */
@Transactional
@Service
public class BlogServiceImp implements BlogService{

    @Autowired
    BolgMapper bolgMapper;

    @Override
    public String myBlog(Integer blogId) {
        Bolg bolg = bolgMapper.selectByPrimaryKey(blogId);
        return bolg.getBlogDescribe();
    }

    @Override
    public boolean isExits(Integer blogid) {
        Bolg bolg = bolgMapper.selectByPrimaryKey(blogid);
        return bolg==null ?  false : true;
    }

    @Override
    public void createBlog(Bolg blog) {
        bolgMapper.insertSelective(blog);
    }

    @Override
    public void deleteByUserId(Integer userId) {
        bolgMapper.deleteByUserId(userId);
    }

}
